package com.frxuexi.shop.adapter

import android.view.View
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.frxuexi.base.db.OrderEntity
import com.frxuexi.base.utils.GlideUtil
import com.frxuexi.shop.R

class OrderAdapter : BaseQuickAdapter<OrderEntity, BaseViewHolder>(R.layout.item_order) {
    override fun convert(helper: BaseViewHolder, item: OrderEntity) {
        GlideUtil.loadRoundImage(helper.getView(R.id.order_iv), item.img)
        helper.setText(R.id.order_title, item.title)
        helper.setText(R.id.order_num, "×${item.num}")
        helper.setText(R.id.order_price, "￥${item.price}")
        helper.setText(R.id.order_sum, "￥${item.sum}")

        helper.getView<TextView>(R.id.btn_order).apply {
            helper.getView<TextView>(R.id.btn_no).let {
                visibility=View.VISIBLE
                it.visibility=View.VISIBLE
                when (item.status) {
                    1 -> {
                        setText("去付款")
                        it.setText("取消订单")
                    }

                    2 -> {
                        setText("发货")
                        it.setText("退货")
                    }

                    3 ->{
                        setText("确认收获")
                        it.setText("退货")
                    }
                    4 -> {
                        setText("去评论")
                        it.setText("退货")
                    }
                    5 -> {
                        visibility=View.GONE
                        it.visibility=View.GONE
                    }
                }
            }

        }
    }
}